//
//  CCVSCommon.m
//  CollectionViewTest
//
//  Created by Pasirstein, David B on 4/24/13.
//  Copyright (c) 2013 Pasirstein, David B. All rights reserved.
//

#import "CCVSCommon.h"
#import "CCVSCustomTypes.h"
#import "CCVSColumn.h"
#import "CCViewStudyViewController.h"
#import "CCVSHyperLink.h"
#import "CCVSImage.h"
#import "CCVSListOfStrings.h"

@implementation CCVSCommon

+(void)displayCCVStestData:(UIViewController*)vc
{
    if ([vc isKindOfClass:[CCViewStudyViewController class]]) {
        
        NSArray * sections = @[@"TEST DATA FOR STUDY",
                               @"Section 2",
                               @"-",
                               @"Section 4"];
        //    self.topics = @[@"Test label - asdfasdasdfadsfasdfasdfasdfasdfafsadsf"];
        //    self.details = @[@"Test Detail"];
        
        
        CCVSHyperLink * hl1 = [[CCVSHyperLink alloc] initWithString:@"click here" andDestination:[NSURL URLWithString:@"http://www.google.com/"]];
        CCVSHyperLink * hl2 = [[CCVSHyperLink alloc] initWithString:@"click here2" andDestination:[NSURL URLWithString:@"http://slashdot.org/"]];
        
        CCVSImage * img1 = [[CCVSImage alloc] init];
        img1.thumbNailURL = [NSURL URLWithString:@"http://www.google.com/images/srpr/logo4w.png"];
        
        CCVSListOfStrings * los = [[CCVSListOfStrings alloc] init];
        los.strings = @[@"item 1",@"item 2",@"item 3", @"aasdfa asdfa asdfasd",
                        @"asdfsa asdfas asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf sadfas asdf asdf asdf asdf asdf asdf afds",
                        @"next fgghj fghj fghj fgjh fgj gfhj fgjh fgj fghj fgj fjh fghj fghj fgjh fgjh fghj gfhj fghj", @"another item", @"more items here",
                        @"adsfasd asdfasd sadfasd asdfads asdfa", @"adfasd asdfasd asdfad"
                        @"adsfa asdf asdf asdf asdf asdf",@"adf asdf asdf asdf",
                        @"asdfa asdf asdf asdf",@"asdfa asdf asdf adf",@"asdf asdf asdf asdf"];
        
        NSArray * t = @[hl1,@"Label 1 asdfasdasdfasdfasdfasdfasdfasdfdsafasdfasdfasdfafs",
                        @"Label 2",
                        @"Image",
                        @"Label 3- very long string that keeps going across multiple rows with extra data and a very long list of extended text and other stuff",
                        @"Label 4",
                        @"Label 5",
                        @"Label 6 - asdfasdfasdasdfasdfadfadsffaaafadffasdfasdfasdfasdfasd",
                        @"List of Strings"];
        NSArray * d = @[hl2,@"dLabel 1",
                        @"dLabel 2 - very long string that keeps going across multiple rows with extra data and a very long list of extended text and other stuff",
                        img1,
                        @"dLabel 3",
                        @[@[@"asdf1 asdf asdf asfd asfd",@"adsf2",hl1,@"Image"],@[@"subsub1",@"subsub2 asdf asdf asfd asdfasdf  asdf asdf asfd asfd",hl2,img1]],
                        @"dLabel 5 - very long string that keeps going across multiple rows with extra data and a very long list of extended text and other stuff",
                        @"dLabel 6",
                        los];

        CCVSColumn * col1 = [[CCVSColumn alloc] init];
        for (int i = 0; i < [sections count]; i++) {
            [col1 addSection:sections[i] withTopics:t withDetails:d];
        }
        CCVSColumn * col2 = [[CCVSColumn alloc] init];
        for (int i = 0; i < [sections count]; i++) {
            [col2 addSection:sections[i] withTopics:t withDetails:d];
        }
        [col2 addSection:@"Empty Section" withTopics:nil withDetails:nil];
        for (int i = 0; i < [sections count]; i++) {
            [col2 addSection:sections[i] withTopics:t withDetails:d];
        }
        CCVSColumn * col3 = [[CCVSColumn alloc] init];
        for (int i = 0; i < [sections count]; i++) {
            [col3 addSection:sections[i] withTopics:d withDetails:nil];
        }
        [col3 addSection:@"Empty Section" withTopics:@[@"not exactly"] withDetails:nil];
        for (int i = 0; i < [sections count]; i++) {
            [col3 addSection:sections[i] withTopics:t withDetails:d];
        }
        
        col1.percentWidthOfSuperView = 0.4;
        //((CCViewStudyViewController*)vc).disableScaleToFit = YES;
        int count = (((CCViewStudyViewController*)vc).ccvsColumns) ? [((CCViewStudyViewController*)vc).ccvsColumns count] : 0;
        NSMutableArray * cols = [[NSMutableArray alloc] init];
        [cols addObject:col2];
        [cols addObject:col3];
        for (; count >= 0; count--) {
            //[cols addObject:col3];
        }
        ((CCViewStudyViewController*)vc).ccvsColumns = cols;
        
        
//        [(CCViewStudyViewController*)vc refreshCollectionView:vc];
        [((CCViewStudyViewController*)vc).collectionView reloadData];
        
    }
}


@end
